home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / bench.ps < prev    next >
Text File  |  1994-08-01  |  2KB  |  78 lines

  1. %    Copyright (C) 1993 Aladdin Enterprises.  All rights reserved.
  2. %
  3. % This file is part of Ghostscript.
  4. %
  5. % Ghostscript is distributed in the hope that it will be useful, but
  6. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. % to anyone for the consequences of using it or for whether it serves any
  8. % particular purpose or works at all, unless he says so in writing.  Refer
  9. % to the Ghostscript General Public License for full details.
  10. %
  11. % Everyone is granted permission to copy, modify and redistribute
  12. % Ghostscript, but only under the conditions described in the Ghostscript
  13. % General Public License.  A copy of this license is supposed to have been
  14. % given to you along with Ghostscript so you can know your rights and
  15. % responsibilities.  It should be in a file named COPYING.  Among other
  16. % things, the copyright notice and this notice must be preserved on all
  17. % copies.
  18.  
  19. % bench.ps
  20. % This file is a "wrapper" for benchmarking.
  21. % It writes timing results on a file called:
  22.  
  23. /BOF where { pop } {
  24.   /BOF (bench.out) def
  25. } ifelse
  26.  
  27.         % Make sure all execution occurs under a `save'.
  28.  
  29. save pop
  30.  
  31.         % Set the output device to an image device.
  32.  
  33. /Resolution where { pop } { /Resolution 100 def } ifelse
  34. [ Resolution 72.0 div 0 0 Resolution -72.0 div 0 792 ]
  35.   Resolution 8.5 mul cvi
  36.   Resolution 11.0 mul cvi
  37.   <00 ff>
  38. makeimagedevice
  39. setdevice
  40.  
  41.         % Redefine 'run' so that it collects timing information.
  42.  
  43. /.orig.run /run load def
  44. /.run.finish    % <file> <time> .run.finish <file>
  45.  { usertime exch sub
  46.    1 index =string cvs .bench.file exch writestring
  47.    .bench.file (: run time = ) writestring
  48.    =string cvs .bench.file exch writestring
  49.    .bench.file ( ms\n) writestring
  50.    .bench.file flushfile
  51.  } bind def
  52. /run        % <string> run -
  53.  {        % We construct a bound procedure here so that
  54.         % we can invoke run recursively.
  55.    cvlit
  56.    2
  57.     { /.orig.run load
  58.       save countdictstack 3 index usertime /.run.finish cvx
  59.       7 array astore cvx exec
  60.       exch countdictstack exch sub { end } repeat
  61.       exch restore
  62.     }
  63.    repeat
  64.         % Don't do the save & restore the last time.
  65.    /.orig.run load
  66.    1 index usertime /.run.finish cvx
  67.    5 array astore cvx exec pop
  68.  } bind odef
  69.  
  70.         % Force a quit after processing files.
  71.  
  72. /.bench.file BOF (w) file def
  73. /executive { .bench.file closefile quit } def
  74.  
  75.         % Make sure we don't incur any pauses.
  76.  
  77. /NOPAUSE true def
  78.